/**
 * 产品分类列表
 * 文件命名格式：zmn.模块名称.表名称.功能.jas
 * @author duanzuocai
 * @since 2018/10/18
 */
layui.define(['index', 'form', 'table', 'laypage', 'layedit', 'laydate'], function (exports) {
    var $ = layui.$;
    var form = layui.form;
    var layer = layui.layer;
    var table = layui.table;
    var laypage = layui.laypage;

    var cols = [
        [
            {field: 'pointId', type: 'checkbox', fixed: 'left', width: 50, align: 'center'},
            {field: 'pointId', title: 'ID', width: 120, align: 'center', unresize: true, sort: false},
            {
                field: 'status', title: '状态', width: 80, align: 'center', unresize: true, templet: function (d) {
                    return zmnEnum.STATUS[d.status];
                }
            },
            {field: 'name', title: '名称', width: 250, align: 'center', unresize: true, sort: false},
            {field: 'company', title: '公司', width: 100, align: 'center', unresize: true, sort: false},
            {field: 'province', title: '省', width: 100, align: 'center', unresize: true, sort: false},
            {field: 'city', title: '市', width: 100, align: 'center', unresize: true, sort: false},
            {field: 'county', title: '区', width: 100, align: 'center', unresize: true, sort: false},
            {field: 'address', title: '地扯', width: 100, align: 'center', unresize: true, sort: false},
            {field: 'longitude', title: '经度', width: 100, align: 'center', unresize: true, sort: false},
            {field: 'latitude', title: '纬度', width: 100, align: 'center', unresize: true, sort: false},
            {field: 'mapData', title: '地图数据', width: 200, align: 'center', unresize: true, sort: false},
            {field: 'creater', title: '创建人', width: 150, align: 'center', unresize: true},
            {field: 'createTime', title: '创建时间', templet: '#createTime', width: 200, align: 'center', unresize: true,
                templet :function (row){
                    return zmnUtil.createTime(row.createTime);
                }
            }, {field: 'updater', title: '编辑人', width: 150, align: 'center', unresize: true},
            {field: 'updateTime', title: '编辑时间', width: 200, align: 'center', unresize: true,
                templet :function (row){
                    return zmnUtil.createTime(row.createTime);
                }
            }, {
                fixed: 'right', title: '操作', width: 120, align: 'center', templet:
                    '<div>' +
                    (json.hasEdit ? '<a lay-href="/point/detail.action?pointId={{d.pointId}}" class="layui-btn layui-btn-xs"><i class="layui-icon">&#xe642;</i>编辑</a>' : '') +
                    '</div>'
            }
        ]
    ];
    table.render({
        elem: "#zmn-point-table",
        toolbar: "#zmn-point-table-tool",
        title: "分类列表",
        data: json.items,
        limit: json.pageSize,
        cols: cols,
        page: true,
        height: 'full-120'
    });

    laypage.render(zmnPage.laypageOptions(json));

    var ids = new Array();

    // 选择（全选或单选）
    table.on("checkbox(zmn-point-table)", function () {
        ids = zmnPage.layIdsChecked(json.items, "pointId");
    });

    // 启用/停用
    table.on("toolbar(zmn-point-table)", function (obj) {
        if (obj.event != "start" && obj.event != "stop") {
            return;
        }
        if (ids.length === 0) {
            return layer.alert("请至少选择一个网点！");
        }
        zmnPage.layStartStop(obj, "/point/updateStatus.action", ids.join(","));
    });

    // 修改排序
    table.on("edit(zmn-point-table)", function (obj) {
        zmnPage.laySort(obj, "/point/updateSort.action", obj.data.pointId);
    });

    //对外暴露的接口
    exports('art_categ', {});
});